#include "DbPart.h"
#include "connectpool.h"
#include <sstream>
#include <vector>
#include "Game.h"
#include "Logic.h"
#include "RedisClient.h"


//#define  MOD_DENOMINATOR (20)


CDbPart::CDbPart()
{
	m_dbHandler = NULL;
}

CDbPart::~CDbPart()
{
}

bool CDbPart::UpdateUserAllData(const unsigned int uid, const unsigned int game_id, const std::string& info)
{
	ostringstream ossSQL;

	ossSQL << "insert into game_userinfo_" << uid % MOD_DENOMINATOR << "(uid, game_id, userinfo) values(" << uid << ", "<<game_id <<", '"<<info << "') ON DUPLICATE Key Update userinfo = VALUES(userinfo)";
	
	log_debug("sql = %s", ossSQL.str().c_str());

	if (m_dbHandler->m_pMysqlConn->GetConnect() == NULL)
	{
		m_dbHandler->m_strError = m_dbHandler->m_pMysqlConn->What();
		log_error("UpdateUserAllData Error: %s\r Sql=%s \n", m_dbHandler->m_pMysqlConn->What().c_str(), ossSQL.str().c_str());

		return false;
	}

	return m_dbHandler->UpdateSql(ossSQL.str().c_str());
}
